package com.tangdada.whacmole;

import android.app.Activity;
import android.content.res.Resources;
import android.os.Bundle;

import com.support.libs.App;
import com.support.libs.utils.graphics.ImageCache;


public class GameActivity extends Activity {

    //屏幕缩放比率
    public static final int SCREEN_WIDTH;
    public static final int SCREEN_HEIGHT;
    public static final float SCALE_X;
    public static final float SCALE_Y;

    public static ImageCache imageCache;

    public static int sPlayTimes = 2;

    public static boolean sMusicSwitch = true;

    private GameController mController;

    static {
        Resources resources = App.sInstance.getResources();
        SCREEN_WIDTH = resources.getDisplayMetrics().widthPixels;
        SCREEN_HEIGHT = resources.getDisplayMetrics().heightPixels;
        SCALE_X = SCREEN_WIDTH / 750.0f;
        SCALE_Y = SCREEN_HEIGHT / 1334.0f;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        sMusicSwitch = getSharedPreferences("game", MODE_PRIVATE).getBoolean("music", false);
        GameView view = new GameView(this, SCREEN_WIDTH, SCREEN_HEIGHT);
        mController = new GameController(this);
        view.setGameController(mController);
        if (imageCache == null) imageCache = new ImageCache(this, "game");
        setContentView(view);

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        imageCache.clearCache();
    }

    @Override
    protected void onStop() {
        super.onStop();
        mController.onStop();
    }

    @Override
    protected void onResume() {
        super.onResume();
        mController.onResume();
    }
}